package org.dftproject.genesis.ui.presentation.stackcontrol;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Item;

public class StackItem extends Item {
	
	private final StackControl parent;
	
	public StackItem(StackControl parent, int style) {
		super(parent, style);
		this.parent = parent;
		
		parent.createStackItem(this);
	}
	
	@Override
	public void setText(String text) {
		super.setText(text);
		StackHeaderFigure figure = parent.getStackItemHeaderFigure(this);
		if (figure != null)
			figure.setText(text);
	}
	
	@Override
	public void setImage(Image image) {
		super.setImage(image);
		StackHeaderFigure figure = parent.getStackItemHeaderFigure(this);
		if (figure != null)
			figure.setIcon(image);
	}

	public void setSelection() { 
		parent.setSelection(this);
	}

	public StackControl getTabControl() {
		return parent;
	}
	
}
